package com.cskaoyan.controller.searchController;

import com.cskaoyan.model.vo.BaseRespVo;
import com.cskaoyan.model.vo.searchvo.SearchIndexVo;
import com.cskaoyan.model.vo.searchvo.WxGoodsListVo;
import com.cskaoyan.model.vo.systemvo.UserIndexVo;
import com.cskaoyan.service.SearchService;
import com.fasterxml.jackson.databind.ser.Serializers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SearchController {

    @Autowired
    SearchService searchService;

    @RequestMapping("/wx/user/index")
    public BaseRespVo userIndex(){
        UserIndexVo userIndexVo = searchService.userIndex();
        return BaseRespVo.ok(userIndexVo);
    }

    @RequestMapping("/wx/search/index")
    public BaseRespVo searchIndex(){
        SearchIndexVo searchIndexVo = searchService.searchIndex();
        return BaseRespVo.ok(searchIndexVo);
    }

    @RequestMapping("/wx/goods/list")
    public BaseRespVo goodsList(Integer page, Integer size, String sort, String order, String keyword, Integer categoryId){
        WxGoodsListVo wxGoodsListVo = searchService.goodsList(page,size,sort,order,keyword,categoryId);
        return BaseRespVo.ok(wxGoodsListVo);
    }

    @RequestMapping("/wx/search/clearhistory")
    public BaseRespVo clearHistory(){
        searchService.clearHistory();
        return BaseRespVo.ok();
    }

    @RequestMapping("/wx/search/helper")
    public BaseRespVo search(String keyword){
        return BaseRespVo.ok(null);
    }
}
